﻿package com.ouken.tool;



import java.util.ArrayList;

import com.ouken.activity.R;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DeviceslistAdapter extends BaseAdapter {
	Context context;  
	ArrayList<Device> contents; 
    
	public DeviceslistAdapter(Context context,ArrayList<Device> contents) {
		this.context=context;  
        this.contents=contents;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return contents.size();  
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return "ok";  
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;  
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView==null){  
            LayoutInflater inflater=LayoutInflater.from(context);  
            convertView=inflater.inflate(R.layout.activity_device_list_item, null);  
        }  
        ImageView device_logo=(ImageView)convertView.findViewById(R.id.device_logo);  
        TextView device_name=(TextView)convertView.findViewById(R.id.device_name);  
        ImageView device_wifi_status=(ImageView)convertView.findViewById(R.id.device_wifi_status);  
        TextView device_description=(TextView)convertView.findViewById(R.id.device_description);  
        
            
        device_logo.setImageResource(contents.get(position).getDeviceLogo());
        device_name.setText(contents.get(position).getDeviceName());
        device_wifi_status.setImageResource(contents.get(position).getDeviceSignal());
        device_description.setText(contents.get(position).getDeviceDescription());
     
       
        return convertView;  
	}

}
